package com.coocaa.cirrus.common.base.enums;

import java.util.HashMap;

/**
 * @author bijiahao
 * @date : 2025/10/21 17:15
 * @description
 */
public enum HttpResponseEnum {
    SYSTEM_SUCCESS("success", 1000, "成功"),
    SYSTEM_FAILED("fail", 2000, "失败"),
    ILLEGAL("fail", 2001, "参数缺失或不合法"),
    SYSTEM_EXCEPTION("fail", 2002, "系统繁忙,请稍后再试"),
    SESSION_OUT("sessionOut", 9999, "您还未登录,请先登录");

    private String result;
    private int code;
    private String msg;

    private HttpResponseEnum(String result, int code, String msg) {
        this.result = result;
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getResult() {
        return this.result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public static boolean isSuccess(int code) {
        return SYSTEM_SUCCESS.code == code;
    }

    public HashMap<String, Object> toMap() {
        HashMap<String, Object> map = new HashMap();
        map.put("result", this.result);
        map.put("code", this.code);
        map.put("msg", this.msg);
        return map;
    }
}
